<?php

	include_once('../sys/sys.php');
	header('Content-Type: text/html; charset=utf-8');
	
	$action = $_GET['action'];
	$spc = $_GET['spc'];
	if($action != 'acr'){
		show_normal_mesR('操作错误','操作错误','操作错误');
	}
	
	
	$wjcontent = file_get_contents("http://jdxi.net/xemh/");
	//获取最大数
	$nummax = explode('<div id="post-1594" class="post-home"><div class="post-thumbnail"> ',$wjcontent);
	$nummax = explode('<img src="',$nummax[1]);
	$nummax = explode('href="http://jdxi.net/xemh/',$nummax[0]);
	$nummax = explode('/"',$nummax[1]);
	$nummax = $nummax[0];
	unset($wjcontent);
	//获取数据库中的总计数
	$result = $DB->build_and_exec_query(
			array('select' => 'COUNT(*) as max','from'   => 'xemh','where'	=> "1 " ,)
	);
	//从总数之后开始采集
	$current_num = $result['max'] + 1;
	//打开每页开始采集
	for ($i=$current_num;$i<=$nummax;$i++){
		//构造每页URl
		$page_url = 'http://jdxi.net/xemh/' . $i . '/';
		$page_content = file_get_contents($page_url);
		$url = explode('" width="',$page_content);
		$url = explode(' src="',$url[0]);
		$url = $url[count($url) - 1];
		//插入数据库
		$DB->do_insert( 'xemh', array(
				'id'				=> $i,
				'url'					=> $url,
		)		);
		if ($result === false) {
			show_normal_mesR('无法添加当前漫画','添加出错','添加');
		}
		echo "采集完第" . $i . "张<BR>";
	}
	echo "采集完毕";
	ob_end_flush();
	exit;
	
	
	
	
?>